/**
 * 
 */
package cn.com.gzheroli.core.util;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lichangrong
 *
 */
public class RequestUtil {
	public static Map convertParameterToMap(HttpServletRequest request){
		Enumeration<String> e = request.getParameterNames();//参数名
	    Map<String,Object> para=new HashMap<String,Object>();
	    while(e.hasMoreElements()){
	        String paramName = e.nextElement();//即是JavaBean中的属性名称
	        String paramValue = request.getParameter(paramName);
	        para.put(paramName, paramValue);
	    }
	    return para;
	}
	 //得到所有的消息头
	public static Map convertHeaderToMap(HttpServletRequest request) {
        Enumeration<String> e = request.getHeaderNames();
        Map<String,Object> para=new HashMap<String,Object>();
        while(e.hasMoreElements()){
            String headerName = e.nextElement();//透明称
            Enumeration<String> headerValues = request.getHeaders(headerName);
            while(headerValues.hasMoreElements()){
                System.out.println(headerName+":"+headerValues.nextElement());
            }
            para.put(headerName, headerValues);
        }
        return para;
         
    }
	
}
